package com.ruoyi.web.controller.mes;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.ruoyi.web.domain.vo.InnerAllotVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.MesInnerallotInfo;
import com.ruoyi.web.service.IMesInnerallotInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 内部调拨单Controller
 * 
 * @author wxt
 * @date 2024-01-22
 */
@Api("纸张内部调拨单管理")
@RestController
@RequestMapping("/mes/Innerallot/info")
public class MesInnerallotInfoController extends BaseController
{
    @Autowired
    private IMesInnerallotInfoService mesInnerallotInfoService;

    /**
     * 查询内部调拨单列表
     */
    @ApiOperation("查询内部调拨单列表")
    @GetMapping("/list")
    public TableDataInfo list(MesInnerallotInfo mesInnerallotInfo)
    {
        startPage();
        List<MesInnerallotInfo> list = mesInnerallotInfoService.selectMesInnerallotInfoList(mesInnerallotInfo);
        return getDataTable(list);
    }

    /**
     * 导出内部调拨单列表
     */
    @ApiOperation("导出内部调拨单列表")
    @Log(title = "内部调拨单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public AjaxResult export(HttpServletResponse response, MesInnerallotInfo mesInnerallotInfo)
    {
        List<MesInnerallotInfo> list = mesInnerallotInfoService.selectMesInnerallotInfoList(mesInnerallotInfo);
        ExcelUtil<MesInnerallotInfo> util = new ExcelUtil<MesInnerallotInfo>(MesInnerallotInfo.class);
        //util.exportExcel(response, list, "内部调拨单数据");
        return  util.exportExcel( list, "内部调拨单数据");
    }

    /**
     * 获取内部调拨单详细信息
     */
    @ApiOperation("获取内部调拨单详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mesInnerallotInfoService.selectMesInnerallotInfoById(id));
    }


    /**
     * 内部调拨单明细查询
     */
    @ApiOperation("内部调拨单明细查询")
    @PostMapping("/Detail")
    public TableDataInfo Detail(@RequestBody Map<String,Object> params)
    {
        //startPage();
        PageHelper.startPage((Integer) params.get("pageNum"), (Integer) params.get("pageSize"));
        MesInnerallotInfo Innerallot=new MesInnerallotInfo();
        Innerallot.setParams(params);
        List<InnerAllotVo> list = mesInnerallotInfoService.selectMesDetaillist(Innerallot);
        return getDataTable(list);
    }


    /**
     * 新增内部调拨单
     */
    @ApiOperation("新增内部调拨单")
    @Log(title = "内部调拨单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesInnerallotInfo mesInnerallotInfo)
    {
        return toAjax(mesInnerallotInfoService.insertMesInnerallotInfo(mesInnerallotInfo));
    }

    /**
     * 修改内部调拨单
     */
    @ApiOperation("修改内部调拨单")
    @Log(title = "内部调拨单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesInnerallotInfo mesInnerallotInfo)
    {
        return toAjax(mesInnerallotInfoService.updateMesInnerallotInfo(mesInnerallotInfo));
    }

    /**
     * 删除内部调拨单
     */
    @ApiOperation("删除内部调拨单")
    @Log(title = "内部调拨单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesInnerallotInfoService.deleteMesInnerallotInfoByIds(ids));
    }
}
